<template>
  <!-- <el-dialog v-model="useStore.centerDialog" title="修改列表" width="50%" align-center>
    <span>修改</span>
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="useStore.centerDialog = false">取消</el-button>
        <el-button type="primary" @click="useStore.centerDialog = false">
          确定
        </el-button>
      </span>
    </template>
  </el-dialog> -->
  <el-dialog v-model="useStore.centerDialog" title="Shipping address">
    <el-form :model="form">
      <el-form-item label="Promotion name" :label-width="formLabelWidth">
        <el-input v-model="form.name" autocomplete="off" />
      </el-form-item>
      <el-form-item label="Zones" :label-width="formLabelWidth">
        <el-select v-model="form.region" placeholder="Please select a zone">
          <el-option label="Zone No.1" value="shanghai" />
          <el-option label="Zone No.2" value="beijing" />
        </el-select>
      </el-form-item>
    </el-form>
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="useStore.centerDialog = false">取消</el-button>
        <el-button type="primary" @click="updateItems">
          确认
        </el-button>
      </span>
    </template>
  </el-dialog>
</template>

<script setup lang="ts">
import { reactive } from 'vue'
import useIndexStore from '@s/index'
import { updateCates } from '@a/home'
import{ ElMessage } from 'element-plus'
import { useRouter } from 'vue-router'
const router = useRouter()
const useStore = useIndexStore()
const updateItems = () => {
  updateCates().then(res => {
    if(res.data.code === 200) {
      ElMessage({
        type:'success',
        message: res.data.msg,
        duration: 1500,
        onClose: () => {
          router.go(0)
        }
      })
    }
  })
}

const form = reactive({
  name: '',
  region: '',
  date1: '',
  date2: '',
  delivery: false,
  type: [],
  resource: '',
  desc: '',
})

const formLabelWidth = '140px'
</script>

<style scoped lang="scss">
.el-button--text {
  margin-right: 15px;
}
.el-select {
  width: 300px;
}
.el-input {
  width: 300px;
}
.dialog-footer button:first-child {
  margin-right: 10px;
}


</style>